package cn.mesmile.excel.service.impl;

import cn.mesmile.excel.entity.Employee;
import cn.mesmile.excel.mapper.EmployeeMapper;
import cn.mesmile.excel.mapper.UserMapper;
import cn.mesmile.excel.service.EmployeeService;
import cn.mesmile.excel.service.UserService;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author zb
 * @date 2021/4/21 15:10
 * @Description
 */
@AllArgsConstructor
@Transactional(rollbackFor = Exception.class, propagation = Propagation.SUPPORTS, readOnly = true)
@Service
public class EmployeeServiceImpl extends ServiceImpl<EmployeeMapper, Employee> implements EmployeeService {

    private final EmployeeMapper employeeMapper;

    @Transactional(rollbackFor = Exception.class)
    @Override
    public void deleteData(String key) {
        Map<String, Object> stringObjectHashMap = new HashMap<>();
        stringObjectHashMap.put("c", "5");
        employeeMapper.deleteByMap(stringObjectHashMap);
    }

    @Transactional(rollbackFor = Exception.class)
    @Override
    public void save(List<Employee> employees) {
        for (Employee employee : employees) {
            employeeMapper.insert(employee);
        }

    }


}
